﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DinhMuc.Public;
namespace DinhMuc.DAL
{
  public  class tblNguyenVatLieuDAL
    {
      clsConnect cn = new clsConnect();
      public DataTable bangNVL()
      {
          return cn.LoadTableStore("sp_nguyenVatLieu_select");
      }
      public DataTable dsNhomNVL()
      {
          return cn.LoadTableStore("sp_nhomNVL_select");
      }
      public DataTable DVT()
      {
          return cn.LoadTableStore("sp_DVT_select");
      }
      public DataTable bangNVL(string manvl)
      {
          int para =1;
          string[] name = new string[para];
          object[] value = new object[para];
          name[0] = "@maNVL";
          value[0] = manvl;
          return cn.LoadTable_loc("sp_nguyenVatLieu_selectByMaNVL", name, value, para);
      }
      public void import(string sql, tblNguyenVatLieuPublic p)
      {
          int para = 5;
          string[] name = new string[para];
          object[] value = new object[para];
          name[0] = "@A";
          name[1] = "@B";
          name[2] = "@C";
          name[3] = "@D";
          name[4] = "@E";
          value[0] = p.maNVL;
          value[1] = p.tenNVL;
          value[2] = p.MaNhom;
          value[3] = p.DVT;
          value[4] = p.thongTinNCC;
          cn.UpdateTable(sql, name, value, para);
      }
      public int themNVL(tblNguyenVatLieuPublic p)
      {
          int para = 5;
          string[] name = new string[para];
          object[] value = new object[para];
          name[0]="@maNVL";
          name[1]="@tenNVL";
          name[2] ="@maNhom";
          name[3]="@DVT";
          name[4]="@thongTinNCC";
          value[0] = p.maNVL;
          value[1] = p.tenNVL;
          value[2] = p.MaNhom;
          value[3] = p.DVT;
          value[4] = p.thongTinNCC;
          return cn.UpdateTableStore("sp_nguyenVatLieu_insert", name, value, para);
      }
      public int suaNVL(tblNguyenVatLieuPublic p)
      {
          int para = 5;
          string[] name = new string[para];
          object[] value = new object[para];
          name[0] = "@maNVL";
          name[1] = "@tenNVL";
          name[2] = "@maNhom";
          name[3] = "@DVT";
          name[4] = "@thongTinNCC";
          value[0] = p.maNVL;
          value[1] = p.tenNVL;
          value[2] = p.MaNhom;
          value[3] = p.DVT;
          value[4] = p.thongTinNCC;
          return cn.UpdateTableStore("sp_nguyenVatLieu_update", name, value, para);
      }
      public int xoaNVL(string maNVL)
      {
          int para = 1;
          string[] name = new string[para];
          object[] value = new object[para];
          name[0] = "@maNVL";
          value[0] = maNVL;
          return cn.UpdateTableStore("sp_nguyenVatLieu_delete", name, value, para);
      }
    }
}
